﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Kindohm.KSynth.UI
{
    public partial class VoiceSlider : UserControl
    {
        public VoiceSlider()
        {
            InitializeComponent();
            this.ValueFormat = "###0";
            //this.slider.ValueChanged += new RoutedPropertyChangedEventHandler<double>(slider_ValueChanged);
            this.slider.MouseLeftButtonUp += new MouseButtonEventHandler(slider_MouseLeftButtonUp);
            this.SetSliderValueText();
        }

        void slider_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            this.OnValueChanged();
        }

        void OnValueChanged()
        {
            this.SetSliderValueText();
            if (this.ValueChanged != null)
                this.ValueChanged(this, EventArgs.Empty);
        }

        void SetSliderValueText()
        {
            this.valueText.Text = slider.Value.ToString(this.ValueFormat);
        }

        public string ValueFormat
        {
            get;
            set;
        }

        public double SmallChange
        {
            get { return this.slider.SmallChange; }
            set { this.slider.SmallChange = value; }
        }

        public double LargeChange
        {
            get { return this.slider.LargeChange; }
            set { this.slider.LargeChange = value; }
        }

        public double Minimum
        {
            get { return this.slider.Minimum; }
            set { this.slider.Minimum = value; }
        }

        public double Maximum
        {
            get { return this.slider.Maximum; }
            set { this.slider.Maximum = value; }
        }

        public double Value
        {
            get { return this.slider.Value; }
            set
            {
                this.slider.Value = value;
                this.OnValueChanged();
            }
        }

        public string Title
        {
            get { return this.name.Text; }
            set { this.name.Text = value; }
        }

        public event EventHandler ValueChanged;

    }
}
